var pages=0;
var cont=1;
var pageSize=20;
var timev=Math.floor(new Date().getTime()/1000);
$(".wrap").css("height",$(window).height());
getlist();
function getlist() {
    $.ajax({
        type : "GET",
        url : getRequestUrl("/user/get_unlock"),
        data:{
            timestamp:timev,
            search_type:2,
            page_num:cont,
            page_size:pageSize
        },
        success : function(datas) {
            console.log(datas);
            pages=datas.response_params.total_cnt;
            var arr=datas.response_params.result;
            var strs="";
            $.each(arr,function (i,el) {
                strs+=`<div class="m-user-messageCenter pr" data-id=`+el.user_id+` onclick="getuseInfo(this)">
                                <div class="system-messagesunlock">
                                    <img src=`+el.portrait+`>
                                    <div class="unlock">
                                        <h2>`+el.nick_name+`</h2>
                                        <span>`+gstime(el.insert_time)+`</span>
                                    </div>
                                    <p>`+el.desc+`</p>
                                </div>
                          </div>`
            });
            $(strs).appendTo("#list");
            $("#loading").hide();
            $(".weui-loadmore").hide(500);
        },
        error : function(err) {
        	dealCPErrorResponse(err);
        }
    });
}

function gcscroll(obj) {
    var $this =$(obj),
        viewH =$this.height(),//可见高度
        contentH =$this.get(0).scrollHeight,//内容高度
        scrollTop =$this.scrollTop();//滚动高度
    // console.log("可见高度"+viewH);
    // console.log("内容高度"+contentH);
    // console.log("滚动高度"+scrollTop);
    if(contentH - viewH - scrollTop <=1) { //到达底部100px时,加载新内容
        var nowpage=pages%pageSize==0?(pages/pageSize):(Math.floor(pages/pageSize)+1);
        if(nowpage===cont){
            return false;
            //getlist();
        }else {
            $(".weui-loadmore").show();
            cont+=1;
            getlist();
        }

    }
}
function getuseInfo(obj) {
    var $this=$(obj);
    var id=$this.attr("data-id");
    window.location.href="Personal-information.html?userid="+id;
}